1454B - Unique Bid Auction - CodeForces Solution


implementation *800

Please click on ads to support us..

Python Code:

from collections import Counter , deque
for s in [*open(0)][2::2]:
    s = list(map(int,s.split()))
    x = min(s)
    arr = Counter(s)
    lst = deque()
    for key , value in arr.items():
        if value == 1:
            lst.append(key)
    lst = sorted(lst)
    if lst:
        x = lst[0]
        print(s.index(x)+1)
    else:
        print(-1)

C++ Code:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#define ll long long
#define pcl std::pair<char, long long>
#define IOS ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0)
#define endl "\n"
const int maxn=1e6;
int t,n, m;
void solve()
{
	std::cin>>n;
	std::map<int,int>num,pos;
	for(int i=1;i<=n;i++){
		int x;
		std::cin>>x;
		num[x]++;
		pos[x]=i;
	}
	int ans=-1;
	for(auto it:num){
		if(it.second==1){
			ans=pos[it.first];
			break;
		}
	}
	std::cout<<ans<<endl;
	
}
int main(){
	std::IOS;
	std::cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
									  		    	  	 	  					


Comments

Submit
0 Comments
More Questions

199A - Hexadecimal's theorem
519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite
182B - Vasya's Calendar
934A - A Compatible Pair
1618F - Reverse
1684C - Column Swapping
57C - Array
1713D - Tournament Countdown
33A - What is for dinner
810A - Straight A
1433C - Dominant Piranha
633A - Ebony and Ivory
1196A - Three Piles of Candies
299A - Ksusha and Array
448B - Suffix Structures
1092B - Teams Forming
1166C - A Tale of Two Lands
544B - Sea and Islands
152B - Steps
1174D - Ehab and the Expected XOR Problem
1511A - Review Site
1316A - Grade Allocation